package cn.openea.perpartner.meily.web.controller;

import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.meily.web.entity.dto.QrCodeDto;
import cn.openea.perpartner.meily.web.entity.dto.QrCodeVo;
import cn.openea.perpartner.meily.web.service.IQrCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @author Weird077
 * @description TODO
 * @date 2022-12-28 14:38
 */
@Api(tags = "二维码与海报")
@RestController
@RequestMapping("/applets")
public class QrCodeController extends BaseController {
    @Autowired
    private IQrCodeService qrCodeService;

    @ApiOperation("获取手机号")
    @PostMapping("/getPhoneNumber")
    public String getPhoneNumber(@RequestBody QrCodeDto dto) {
        return qrCodeService.getPhoneNumber(dto.getCode());
    }
    @ApiOperation("获取二维码")
    @PostMapping("/create/qr/code")
    public AjaxResult getQrCode(@RequestBody QrCodeVo vo) throws IOException {
        return AjaxResult.success("生成二维码成功",qrCodeService.getQrCode(vo));
    }
    @ApiOperation("获取海报-按vo参数条件")
    @PostMapping("/create/poster")
    public AjaxResult getPoster(@RequestBody QrCodeDto dto) throws IOException {
        return AjaxResult.success("生成二维码成功", qrCodeService.getPoster(dto));
    }

}
